#include "stdafx.h"

const double NormalProperty::rotateSpeed = 7;
const double NormalProperty::time0 = 0.3;

NormalProperty::NormalProperty(int x, int y) :AbstractProperty(x, y)
{
	circle = ImageMgr::getInstance()->get("image/property/circle.png");
}

NormalProperty::~NormalProperty()
{
}

bool NormalProperty::update(double dtime)
{
	time += dtime;

	angle += dtime*rotateSpeed;

	if (dying)
	{
		disappearTime += dtime;
		if (disappearTime > time0)
		{
			return false;
		}
	}

	return true;
}

bool NormalProperty::render()
{
	if (dying)
	{
		circle->render(getDisplayX(), getDisplayY(), circle->getWidth()*(1 - disappearTime / time0), circle->getHeight()*(1 - disappearTime / time0), angle);
	}
	else
	{
		circle->render(getDisplayX(), getDisplayY(), angle);
		img->render(getDisplayX(), getDisplayY(), 0);
	}

	return true;
}

void NormalProperty::die()
{
	dying = true;
	disappearTime = 0;
}